 
 
$.ajax({
	url: 'index.php/speed/all',
	//type: '',
	success: function(data){
		//alert('fsd')
		//console.log(eval(data));
		var data = eval(data);
		var l = data.length;
		var data0 = {
			name: '无效数据',
			color: '#999',
			data: []
		};
		var data1 = {
			name: '阻塞',
			color: '#FF3300',
			data: [
				[2,2]
			]
		};
		var data2 = {
			name: '拥堵',
			color: '#FF9900',
			data: []
		};
		var data3 = {
			name: '正常',
			color: '#66CC00',
			data: []
		}
		var data4 = {
			name: '畅通',
			color: '#669900',
			data: []
		};

		var datac = {
			name: '有效数据',
			color: '#ff3300',
			data: []
		}
		for(var i=0; i<data.length; i++){
			//console.log(data[i].car_speed)
			var s = parseInt(data[i]['car_speed']);
			if (s >0) 
			datac.data.push([s,s ]);
			if(data[i]['car_speed'] ==0){
				data0.data.push([s, s]);
				continue;
			}
			if(data[i]['car_speed'] < 5){
				data1.data.push([s, s]);continue;
				 
			}
			if(data[i]['car_speed'] < 13){

				data2.data.push([s, s]);continue;
				//data2.data[data1.data.length] = [data[i]['car_speed'], data[i]['car_speed']];
			}
			if(data[i]['car_speed'] < 29){
				data3.data.push([s, s]);continue;
			}
			if(data[i]['car_speed'] >= 29){
				data4.data.push([s, s]);continue;
			}

		}

		console.log(data2)
	 	console.log(data1.data.length)
	 	console.log(data2.data.length)
	 	console.log(data3.data.length)
	 	console.log(data4.data.length)

		clean(data0, data1, data2, data3, data4)
		clean2(data0, datac)
		clean3(datac);
	},
	error: function(){
		console.log('get data wrong')
	}
})

function clean(data0, data1, data2, data3, data4) {                                                                                  
    $('#clean').highcharts({                                                             
        chart: {                                                                             
            type: 'scatter',                                                                 
            zoomType: 'xy'                                                                   
        },                                                                                   
        title: {                                                                             
            text: '数据聚类图'                        
        },                                                                                   
        subtitle: {                                                                          
            text: '15min'                                                      
        },                                                                                   
        xAxis: {                                                                             
            title: {                                                                         
                enabled: true,                                                               
                text: 'km/h'                                                          
            },                                                                               
            startOnTick: true,                                                               
            endOnTick: true,                                                                 
            showLastLabel: true                                                              
        },                                                                                   
        yAxis: {                                                                             
            title: {                                                                         
                text: 'km/h'                                                          
            }                                                                                
        },                                                                                   
        legend: {                                                                            
            layout: 'vertical',                                                              
            align: 'left',                                                                   
            verticalAlign: 'top',                                                            
            x: 100,                                                                          
            y: 70,                                                                           
            floating: true,                                                                  
            backgroundColor: '#FFFFFF',                                                      
            borderWidth: 1                                                                   
        },                                                                                   
        plotOptions: {                                                                       
            scatter: {                                                                       
                marker: {                                                                    
                    radius: 5,                                                               
                    states: {                                                                
                        hover: {                                                             
                            enabled: true,                                                   
                            lineColor: 'rgb(100,100,100)'                                    
                        }                                                                    
                    }                                                                        
                },                                                                           
                states: {                                                                    
                    hover: {                                                                 
                        marker: {                                                            
                            enabled: false                                                   
                        }                                                                    
                    }                                                                        
                },                                                                           
                tooltip: {                                                                   
                    headerFormat: '<b>{series.name}</b><br>',                                
                    pointFormat: '{point.x} mk/h'                                
                }                                                                            
            }                                                                                
        },                                                                                   
        series: [ data1, data2, data3, data4]                                                                                   
    });                                                                                      
}

function clean2(data0, datac) {   
	data0.data.push([80, 80]);
	data0.data.push([75,75]);                                                                               
    $('#clean2').highcharts({                                                             
        chart: {                                                                             
            type: 'scatter',                                                                 
            zoomType: 'xy'                                                                   
        },                                                                                   
        title: {                                                                             
            text: '全部速度数据'                        
        },                                                                                   
        subtitle: {                                                                          
            text: '15min'                                                      
        },                                                                                   
        xAxis: {                                                                             
            title: {                                                                         
                enabled: true,                                                               
                text: 'km/h'                                                          
            },                                                                               
            startOnTick: true,                                                               
            endOnTick: true,                                                                 
            showLastLabel: true                                                              
        },                                                                                   
        yAxis: {                                                                             
            title: {                                                                         
                text: 'km/h'                                                          
            }                                                                                
        },                                                                                   
        legend: {                                                                            
            layout: 'vertical',                                                              
            align: 'left',                                                                   
            verticalAlign: 'top',                                                            
            x: 100,                                                                          
            y: 70,                                                                           
            floating: true,                                                                  
            backgroundColor: '#FFFFFF',                                                      
            borderWidth: 1                                                                   
        },                                                                                   
        plotOptions: {                                                                       
            scatter: {                                                                       
                marker: {                                                                    
                    radius: 5,                                                               
                    states: {                                                                
                        hover: {                                                             
                            enabled: true,                                                   
                            lineColor: 'rgb(100,100,100)'                                    
                        }                                                                    
                    }                                                                        
                },                                                                           
                states: {                                                                    
                    hover: {                                                                 
                        marker: {                                                            
                            enabled: false                                                   
                        }                                                                    
                    }                                                                        
                },                                                                           
                tooltip: {                                                                   
                    headerFormat: '<b>{series.name}</b><br>',                                
                    pointFormat: '{point.x} mk/h'                                
                }                                                                            
            }                                                                                
        },                                                                                   
        series: [data0, datac]                                                                                   
    });                                                                                      
}

function clean3( datac) {   
	                                                                             
    $('#clean3').highcharts({                                                             
        chart: {                                                                             
            type: 'scatter',                                                                 
            zoomType: 'xy'                                                                   
        },                                                                                   
        title: {                                                                             
            text: '有效速度数据'                        
        },                                                                                   
        subtitle: {                                                                          
            text: '15min'                                                      
        },                                                                                   
        xAxis: {                                                                             
            title: {                                                                         
                enabled: true,                                                               
                text: 'km/h'                                                          
            },                                                                               
            startOnTick: true,                                                               
            endOnTick: true,                                                                 
            showLastLabel: true                                                              
        },                                                                                   
        yAxis: {                                                                             
            title: {                                                                         
                text: 'km/h'                                                          
            }                                                                                
        },                                                                                   
        legend: {                                                                            
            layout: 'vertical',                                                              
            align: 'left',                                                                   
            verticalAlign: 'top',                                                            
            x: 100,                                                                          
            y: 70,                                                                           
            floating: true,                                                                  
            backgroundColor: '#FFFFFF',                                                      
            borderWidth: 1                                                                   
        },                                                                                   
        plotOptions: {                                                                       
            scatter: {                                                                       
                marker: {                                                                    
                    radius: 5,                                                               
                    states: {                                                                
                        hover: {                                                             
                            enabled: true,                                                   
                            lineColor: 'rgb(100,100,100)'                                    
                        }                                                                    
                    }                                                                        
                },                                                                           
                states: {                                                                    
                    hover: {                                                                 
                        marker: {                                                            
                            enabled: false                                                   
                        }                                                                    
                    }                                                                        
                },                                                                           
                tooltip: {                                                                   
                    headerFormat: '<b>{series.name}</b><br>',                                
                    pointFormat: '{point.x} mk/h'                                
                }                                                                            
            }                                                                                
        },                                                                                   
        series: [datac]                                                                                   
    });                                                                                      
}